package vip.meeet.jdk.loader;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class BaseClassLoader extends ClassLoader{

    @Override
    protected Class<?> findClass(String name) throws ClassNotFoundException {
        System.out.println(name);
        String path = "E:\\esstuido\\base\\target\\classes\\org\\curitis\\bean\\Baba.class";
        Path path1 = Paths.get(path);
        try {
            byte[] bytes = Files.readAllBytes(path1);
            return defineClass("org.curitis.bean.Baba",bytes,0,bytes.length);
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }

    public static void main(String[] args) throws ClassNotFoundException {

        BaseClassLoader loader = new BaseClassLoader();
        String className = "org.curitis.bean.Baba";
//        Class<?> aClass = Class.forName(className);
//        Class.forName(className,true,new BaseClassLoader());
        Class.forName(className,false,new BaseClassLoader());
    }
}
